<template>
  <my-layout sTitle="楼盘">
    <div slot="content">
      <search :wordKey="wordKey" @parentEvent="getFinds"/>
      <floorlist :findsList="findsList"/>
    </div>
  </my-layout>
</template>

<script>
import search from "./components/search";
import floorlist from "./components/floorlist";
export default {
  components: {
    search,
    floorlist
  },
  data() {
    return {
      findsList: [],
      setPage: {
        key: "",
        pageNum: 1,
        pageSize: 10
      },
      wordKey: ""
    };
  },
  methods: {
    async getFinds(msg) {
      const { data } = await this.$http.post("lp/finds", {
        key: msg ? msg : "",
        pageNum: this.setPage.pageNum,
        pageSize: this.setPage.pageSize
      });
      // console.log(data + "11111");
      if (data.code == 0) {
        this.findsList = data.lps;
      }
    },
    async getSearch() {
      let key = this.$route.query.wordKey;
      const { data } = await this.$http.post("word/finds", {
        type: "lp",
        key: key
      });
      if (data.code == 0) {
        this.findsList = data.lps;
      }
    }
  },
  mounted() {
    this.wordKey = this.$route.query.wordKey;
    if (this.wordKey) {
      this.getSearch();
    } else {
      this.getFinds();
    }
  }
};
</script>

<style lang="scss">
</style>
